import java.util.Scanner;

// HJ87 二维数组操作
 public class HJ83 {

     public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         while (sc.hasNext()) {
             int m = sc.nextInt();
             int n = sc.nextInt();
             if (m > 0 && n > 0 && m <= 9 && n <= 9) {
                 int[][] arr = new int[m][n];
                 System.out.println(0);
             } else {
                 System.out.println(-1);
             }

             int x1 = sc.nextInt();
             int y1 = sc.nextInt();
             int x2 = sc.nextInt();
             int y2 = sc.nextInt();
             if (x1 >= 0 && x1 < m && y1 >= 0 && y1 < n && x2 >= 0 && x2 < m && y2 >= 0 &&
                     y2 < n) {
                 System.out.println(0);
             } else {
                 System.out.println(-1);
             }

             int x = sc.nextInt();
             if (x >= 0 && (1 + m) <= 9  && x<=m-1) {
                 System.out.println(0);
             } else {
                 System.out.println(-1);
             }

             int y = sc.nextInt();
             if (y >= 0 && (1 + n) <= 9 && y<=n-1) {
                 System.out.println(0);
             } else {
                 System.out.println(-1);
             }

             int xx = sc.nextInt();
             int yy = sc.nextInt();
             if (xx >= 0 && xx < m && yy >= 0 && yy < n) {
                 System.out.println(0);
             } else {
                 System.out.println(-1);
             }
         }
     }
 }

